<template>
  <div class="m-bottombar">
    <div class="topbar-nav">
      <a
        :class="['menu-item', activePath == item.path ? 'active-menu-item' : '']"
        v-for="(item, index) in menuData"
        :key="item.title"
        :href="item.path"
        :title="item.title"
      >
        <img :src="activePath == item.path ? item.selectedIconPath : item.iconPath" />
        <span>{{ $t("topbar")[index] }}</span>
      </a>
    </div>
  </div>
</template>

<script>
export default {
  props: {},
  data() {
    return {
      activePath: "",
      menuData: [
        {
          title: "首页",
          path: "/m-home",
          iconPath: "https://yunlian-oss-product.oss-cn-hangzhou.aliyuncs.com/website/tab-home.png",
          selectedIconPath: "https://yunlian-oss-product.oss-cn-hangzhou.aliyuncs.com/website/tab-home-active.png"
        },
        {
          title: "二手设备",
          path: "/m-used-machine/excavator-47",
          iconPath: "https://yunlian-oss-product.oss-cn-hangzhou.aliyuncs.com/website/tab-used.png",
          selectedIconPath: "https://yunlian-oss-product.oss-cn-hangzhou.aliyuncs.com/website/tab-used-active.png"
        },
        {
          title: "产品中心",
          path: "/m-products",
          iconPath: "https://yunlian-oss-product.oss-cn-hangzhou.aliyuncs.com/website/tab-shebei.png",
          selectedIconPath: "https://yunlian-oss-product.oss-cn-hangzhou.aliyuncs.com/website/tab-shebei-active.png"
        },
        {
          title: "帮我找车",
          path: "/m-find-car",
          iconPath: "https://yunlian-oss-product.oss-cn-hangzhou.aliyuncs.com/website/tab-find.png",
          selectedIconPath: "https://yunlian-oss-product.oss-cn-hangzhou.aliyuncs.com/website/tab-find-active.png"
        },
        {
          title: "新闻资讯",
          path: "/m-news",
          iconPath: "https://yunlian-oss-product.oss-cn-hangzhou.aliyuncs.com/website/tab-news.png",
          selectedIconPath: "https://yunlian-oss-product.oss-cn-hangzhou.aliyuncs.com/website/tab-news-active.png"
        },
        {
          title: "关于云联",
          path: "/m-about-us",
          iconPath: "https://yunlian-oss-product.oss-cn-hangzhou.aliyuncs.com/website/tab-about.png",
          selectedIconPath: "https://yunlian-oss-product.oss-cn-hangzhou.aliyuncs.com/website/tab-about-active.png"
        }
      ]
    }
  },
  mounted() {
    this.activePath = this.$route.path.includes("m-used-machine") ? "/m-used-machine/excavator-47" : this.$route.path
  },
  computed: {},
  components: {},
  watch: {
    $route(to, from) {
      this.activePath = to.path.includes("m-used-machine") ? "/m-used-machine/excavator-47" : to.path
    }
  },
  methods: {}
}
</script>

<style lang="scss" scoped>
.m-bottombar {
  width: 100%;
  height: 300px;
  background: #fff;
  border-top: 1px solid #f0f0f0;
  position: fixed;
  left: 0;
  bottom: 0;
  z-index: 999;
  .topbar-nav {
    display: flex;
    align-items: center;
    justify-content: space-evenly;
    margin-top: 30px;
    .menu-item {
      display: flex;
      flex-direction: column;
      align-items: center;
      img {
        width: 123px;
        height: 123px;
      }
      span {
        font-family: PingFangSC, PingFang SC;
        font-weight: 400;
        font-size: 51px;
        color: #333;
        line-height: 51px;
        margin-top: 10px;
      }
    }
    .active-menu-item {
      span {
        font-family: PingFangSC, PingFang SC;
        font-weight: 400;
        font-size: 51px;
        color: #fb463f;
        line-height: 51px;
        margin-top: 10px;
      }
    }
  }
}
</style>
